package niit.group5.app;


import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class GameCleanHouseActivity extends Activity implements Runnable, OnTouchListener {
	Thread mThread;
    Runnable mRunnable;
    boolean active = false;
    int mTime = 300;
    ImageView logo;
    
    SoundPool mSoundPool;
    int soundIntroduce ;
    public static boolean soundStatus = true;
    public static Map soundList;
    
    private int INTRO = 0;
    private int LEVEL_1 = 1;
    private int LEVEL_2 = 2;
    private int LEVEL_3 = 3;
    @Override
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        logo =(ImageView)findViewById(R.id.logo);
        logo.setBackgroundResource(R.drawable.splash);
       // soundList.put(INTRO, R.);
        //mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
        //soundIntroduce = mSoundPool.load(getBaseContext(), R.raw.sleep, 1);
        
    }
    @Override
    protected void onResume() {
    	// TODO Auto-generated method stub
    	active = true;
    	mTime=300;
    	super.onResume();
    }
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
    	// TODO Auto-generated method stub
    	if(mThread==null){
    		mThread = new Thread(this);
    		mThread.start();
    	}
    	super.onWindowFocusChanged(hasFocus);
    }
	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			while(active && mTime>0){
				mTime-=10;
				mThread.sleep(300);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}finally{
			startActivity(new Intent(getBaseContext(),MainMenu.class));
			finish();
		}
		
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if(event.getAction()==MotionEvent.ACTION_DOWN){
			active=false;
		}
		return true;
	}
	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
}